home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
bbs
/
pad311.zip
/
STRIPNUM.MH
< prev
next >
Wrap
Text File
|
1996-08-21
|
793b
|
32 lines
#ifndef __STRIPNUM_MH
#define __STRIPNUM_MH
// stripNonNumeric removes all non-numeric characters from the string.
// Returns the number of numeric characters found in the string.
// The original string is modified.
int stripNonNumeric (Ref string: s) {
int: sidx, tidx;
tidx := 1;
for (sidx := 1; sidx <= strlen (s); sidx := sidx + 1) {
if ((s [sidx] >= '0') and (s [sidx] <= '9')) {
s [tidx] := s [sidx];
tidx := tidx + 1;
};
};
s := substr (s,1,tidx-1);
return tidx-1;
}
// stripNonNumericf removes all non-numeric characters from a string
// without modifying the original string. The new string is returned
// by the function.
string stripNonNumericf (string: s) {
stripNonNumeric (s);
return s;
}
#endif